<?php
/**
 * Created by PhpStorm.
 * User: LG
 * Date: 2018/8/8
 * Time: 17:56
 */

namespace app\common\model;


use think\Model;

class EquipmentListsModel extends Model
{
	protected $name = 'equipment_lists';

	// 列表查询
    public function getAll($where=[],$field='*',$page=1,$pageSize=999,$order='')
    {
        $result = $this->where($where)
                ->field($field)
                ->page($page, $pageSize)
                ->order($order)
                ->select();
        return $result;
    }

	// 数量查询
    public function getCount($where=[])
    {
        $result = $this->where($where)->count();
        return $result;
    }

	// 单条查询
	public function getOne($where, $field='*')
    {
        // 根据条件 $where 查询单条数据
        $userInfo = $this->where($where)->field($field)->find();
        // 判断结果 并返回
        if ($userInfo == false) {
            return false;
        }
        return $userInfo;
    }

     // 添加操作
    public function add($data)
    {
        $result = $this->insertGetId($data);
        return $result;
    }

    // 编辑操作
    public function edit($where, $data)
    {
        $result = $this->where($where)->update($data);
        return $result;
    }
}